home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / tegl6b.zip / INTROPAK.EXE / lha / TGRAPH.DOC < prev    next >
Text File  |  1991-08-16  |  11KB  |  333 lines

  1. {-----------------------------------------------------------------------------}
  2. {               TEGL Windows ToolKit II                  }
  3. {          Copyright (C) 1990, TEGL Systems Corporation              }
  4. {                All Rights Reserved.                  }
  5. {-----------------------------------------------------------------------------}
  6. {$I Switches.inc}
  7.  
  8. UNIT TGraph;
  9.  
  10. INTERFACE
  11.  
  12. USES Dos,
  13.      teglfont,
  14.      {$IFDEF TEGLDEMO}
  15.      errorlog,
  16.      {$ENDIF}
  17.      videochk;
  18.  
  19. const
  20.   { GraphResult error return codes: }
  21.   grOk             =     0;
  22.   grNoInitGraph      =    -1;
  23.   grNotDetected      =    -2;
  24.   grFileNotFound     =    -3;
  25.   grInvalidDriver    =    -4;
  26.   grNoLoadMem         =    -5;
  27.   grNoScanMem         =    -6;
  28.   grNoFloodMem         =    -7;
  29.   grFontNotFound     =    -8;
  30.   grNoFontMem         =    -9;
  31.   grInvalidMode      = -10;
  32.   grError         = -11;   { generic error }
  33.   grIOerror         = -12;
  34.   grInvalidFont      = -13;
  35.   grInvalidFontNum   = -14;
  36.  
  37.   { define graphics drivers }
  38.   CurrentDriver = -128; { passed to GetModeRange }
  39.   Detect    = 0;    { requests autodetection }
  40.   CGA        = 1;
  41.   MCGA        = 2;
  42.   EGA        = 3;
  43.   EGA64     = 4;
  44.   EGAMono    = 5;
  45.   IBM8514    = 6;
  46.   HercMono    = 7;
  47.   ATT400    = 8;
  48.   VGA        = 9;
  49.   PC3270    = 10;
  50.  
  51.   { graphics modes for each driver }
  52.   CGAC0      = 0;  { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
  53.   CGAC1      = 1;  { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
  54.   CGAC2      = 2;  { 320x200 palette 2: Green, Red, Brown; 1 page }
  55.   CGAC3      = 3;  { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
  56.   CGAHi      = 4;  { 640x200 1 page }
  57.   MCGAC0     = 0;  { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
  58.   MCGAC1     = 1;  { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
  59.   MCGAC2     = 2;  { 320x200 palette 2: Green, Red, Brown; 1 page }
  60.   MCGAC3     = 3;  { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
  61.   MCGAMed    = 4;  { 640x200 1 page }
  62.   MCGAHi     = 5;  { 640x480 1 page }
  63.   EGALo      = 0;  { 640x200 16 color 4 page }
  64.   EGAHi      = 1;  { 640x350 16 color 2 page }
  65.   EGA64Lo    = 0;  { 640x200 16 color 1 page }
  66.   EGA64Hi    = 1;  { 640x350 4 color  1 page }
  67.   EGAMonoHi  = 3;  { 640x350 64K on card, 1 page; 256K on card, 2 page }
  68.   HercMonoHi = 0;  { 720x348 2 page }
  69.   ATT400C0   = 0;  { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
  70.   ATT400C1   = 1;  { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
  71.   ATT400C2   = 2;  { 320x200 palette 2: Green, Red, Brown; 1 page }
  72.   ATT400C3   = 3;  { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
  73.   ATT400Med  = 4;  { 640x200 1 page }
  74.   ATT400Hi   = 5;  { 640x400 1 page }
  75.   VGALo      = 0;  { 640x200 16 color 4 page }
  76.   VGAMed     = 1;  { 640x350 16 color 2 page }
  77.   VGAHi      = 2;  { 640x480 16 color 1 page }
  78.   PC3270Hi   = 0;  { 720x350 1 page }
  79.   IBM8514LO  = 0;  { 640x480 256 colors }
  80.   IBM8514HI  = 1;  { 1024x768 256 colors }
  81.  
  82.   { Colors for SetPalette and SetAllPalette: }
  83.   Black        = 0;
  84.   Blue           = 1;
  85.   Green        = 2;
  86.   Cyan           = 3;
  87.   Red           = 4;
  88.   Magenta      = 5;
  89.   Brown        = 6;
  90.   LightGray    = 7;
  91.   DarkGray     = 8;
  92.   LightBlue    = 9;
  93.   LightGreen   = 10;
  94.   LightCyan    = 11;
  95.   LightRed     = 12;
  96.   LightMagenta = 13;
  97.   Yellow       = 14;
  98.   White        = 15;
  99.  
  100.   { colors for 8514 to set standard EGA colors w/o knowing their values }
  101.   EGABlack           = 0;      { dark colors }
  102.   EGABlue           = 1;
  103.   EGAGreen           = 2;
  104.   EGACyan           = 3;
  105.   EGARed           = 4;
  106.   EGAMagenta           = 5;
  107.   EGABrown           = 20;
  108.   EGALightgray           = 7;
  109.   EGADarkgray           = 56;      { light colors }
  110.   EGALightblue           = 57;
  111.   EGALightgreen        = 58;
  112.   EGALightcyan           = 59;
  113.   EGALightred           = 60;
  114.   EGALightmagenta      = 61;
  115.   EGAYellow           = 62;
  116.   EGAWhite           = 63;
  117.  
  118.   { Line styles and widths for Get/SetLineStyle: }
  119.   SolidLn    = 0;
  120.   DottedLn   = 1;
  121.   CenterLn   = 2;
  122.   DashedLn   = 3;
  123.   UserBitLn  = 4;    { User-defined line style }
  124.  
  125.   NormWidth  = 1;
  126.   ThickWidth = 3;
  127.  
  128.   { Set/GetTextStyle constants: }
  129.   DefaultFont    = 0;    { 8x8 bit mapped font }
  130.   TriplexFont    = 1;    { "Stroked" fonts }
  131.   SmallFont    = 2;
  132.   SansSerifFont = 3;
  133.   GothicFont    = 4;
  134.  
  135.   HorizDir   = 0;    { left to right }
  136.   VertDir    = 1;    { bottom to top }
  137.  
  138.   UserCharSize = 0;    { user-defined char size }
  139.  
  140.   { Clipping constants: }
  141.   ClipOn  = true;
  142.   ClipOff = false;
  143.  
  144.   { Bar3D constants: }
  145.   TopOn  = true;
  146.   TopOff = false;
  147.  
  148.   { Fill patterns for Get/SetFillStyle: }
  149.   EmptyFill      = 0;    { fills area in background color }
  150.   SolidFill      = 1;    { fills area in solid fill color }
  151.   LineFill      = 2;    { --- fill }
  152.   LtSlashFill      = 3;    { /// fill }
  153.   SlashFill      = 4;    { /// fill with thick lines }
  154.   BkSlashFill      = 5;    { \\\ fill with thick lines }
  155.   LtBkSlashFill   = 6;    { \\\ fill }
  156.   HatchFill      = 7;    { light hatch fill }
  157.   XHatchFill      = 8;    { heavy cross hatch fill }
  158.   InterleaveFill  = 9;    { interleaving line fill }
  159.   WideDotFill      = 10; { Widely spaced dot fill }
  160.   CloseDotFill      = 11; { Closely spaced dot fill }
  161.   UserFill      = 12; { user defined fill }
  162.  
  163.   { BitBlt operators for PutImage: }
  164.   NormalPut    = 0;    { MOV }       { left for 1.0 compatibility }
  165.   CopyPut    = 0;    { MOV }
  166.   XORPut    = 1;    { XOR }
  167.   OrPut     = 2;    { OR  }
  168.   AndPut    = 3;    { AND }
  169.   NotPut    = 4;    { NOT }
  170.  
  171.   { Horizontal and vertical justification for SetTextJustify: }
  172.   LeftText   = 0;
  173.   CenterText = 1;
  174.   RightText  = 2;
  175.  
  176.   BottomText = 0;
  177. { CenterText = 1; already defined above }
  178.   TopText    = 2;
  179.  
  180.  
  181. const
  182.   MaxColors = 15;
  183. type
  184.   PaletteType = record
  185.       Size   : byte;
  186.       Colors : array[0..MaxColors] of shortint;
  187.     end;
  188.  
  189.   LineSettingsType = record
  190.       LineStyle : word;
  191.       Pattern    : word;
  192.       Thickness : word;
  193.     end;
  194.  
  195.   TextSettingsType = record
  196.       Font    : word;
  197.       Direction : word;
  198.       CharSize    : word;
  199.       Horiz    : word;
  200.       Vert    : word;
  201.     end;
  202.  
  203.   FillSettingsType = record          { Pre-defined fill style }
  204.       Pattern : word;
  205.       Color   : word;
  206.     end;
  207.  
  208.   FillPatternType = array[1..8] of byte;  { User defined fill style }
  209.  
  210.   PointType = record
  211.       X, Y : integer;
  212.     end;
  213.  
  214.   ViewPortType = record
  215.       x1, y1, x2, y2 : integer;
  216.       Clip         : boolean;
  217.     end;
  218.  
  219.   ArcCoordsType = record
  220.       X, Y         : integer;
  221.       Xstart, Ystart : integer;
  222.       Xend, Yend     : integer;
  223.     end;
  224.  
  225.  
  226. var
  227.   GraphGetMemPtr  : Pointer;   { allows user to steal heap allocation }
  228.   GraphFreeMemPtr : Pointer;   { allows user to steal heap de-allocation }
  229.  
  230. { *** A matching initgraph w/o videoinit *** }
  231. procedure InitMatch(var GraphDriver:integer; var GraphMode:integer; PathToDriver:String);
  232.  
  233. { *** high-level error handling *** }
  234. function  GraphErrorMsg(ErrorCode:integer):String;
  235. function  GraphResult:integer;
  236.  
  237. { *** detection, initialization and crt mode routines *** }
  238. procedure DetectGraph(var GraphDriver,GraphMode:integer);
  239. function  GetDriverName:string;
  240. procedure InitGraph(var GraphDriver:integer;var GraphMode:integer;PathToDriver:String);
  241. function  RegisterBGIfont(Font:pointer):integer;
  242. function  RegisterBGIdriver(Driver:pointer):integer;
  243. function  InstallUserDriver(DriverFileName:string;AutoDetectPtr:pointer):integer;
  244. function  InstallUserFont(FontFileName:string):integer;
  245. procedure SetGraphBufSize(BufSize:word);
  246. function  GetMaxMode:integer;
  247. procedure GetModeRange(GraphDriver:integer;var LoMode,HiMode:integer);
  248. function  GetModeName(GraphMode:integer):string;
  249. procedure SetGraphMode(Mode:integer);
  250. function  GetGraphMode:integer;
  251. procedure GraphDefaults;
  252. procedure RestoreCrtMode;
  253. procedure CloseGraph;
  254. function  GetX:integer;
  255. function  GetY:integer;
  256. function  GetMaxX:integer;
  257. function  GetMaxY:integer;
  258.  
  259. { *** Screen, viewport, page routines *** }
  260. procedure ClearDevice;
  261. procedure SetViewPort(x1,y1,x2,y2:integer;Clip:boolean);
  262. procedure GetViewSettings(var ViewPort:ViewPortType);
  263. procedure ClearViewPort;
  264. procedure SetVisualPage(Page:word);
  265. procedure SetActivePage(Page:word);
  266.  
  267. { *** point-oriented routines *** }
  268. procedure PutPixel(X,Y:integer;Pixel:word);
  269. functio